public class Leetcode2315 {
    public int countAsterisks(String s) {
        int count = 0;
        boolean flag = true;
        for (char c : s.toCharArray()) {
            if (c == '|') {
                flag = !flag;
            }

            if (flag && c == '*') {
                count++;
            }
        }

        return count;
    }
}
